<template>
    <el-form class="infobar" label-width="70px" size="default">
        <el-avatar :icon="Avatar" shape="circle" :fit="cover" style="width: 70px; height: 70px"/>
        <el-button :icon="Upload" style="width: 30px; height: 30px;" circle/>
        <el-form-item label="用户名">
            {{ userinfoData.realname }}
        </el-form-item>
        <el-form-item label="手机号">
            <el-input placeholder="{{ userinfoData.phonenumber }}" style="width: 240px;" clearable>
                <template #append>
                    <el-button type="primary">
                        发送验证码
                    </el-button>
                </template>
            </el-input>
        </el-form-item>
        <el-form-item label="邮箱">
            <el-input placeholder="your Email here" style="width: 240px;" clearable/>
        </el-form-item> 
        <el-form-item label="住址">
            <el-input placeholder="key in your address" v-model="textarea" type="textarea" :autosize="{minRows: 1, maxRows: 2}" style="width: 240px;" clearable/>
        </el-form-item> 
        <el-form-item label="密码">
            <el-input placeholder="key in your password" style="width: 240px;" clearable/>
        </el-form-item> 
        <el-form-item label="确认密码">
            <el-input placeholder="repeat your password" style="width: 240px;" clearable/>
        </el-form-item> 
        <el-checkbox class="al-left">记住账号</el-checkbox>
        <br>
        <el-button type="primary" @click="updateUserInfo" style="width: 150px; margin-bottom: 4px;">Save</el-button> 
    </el-form> 
</template>

<script>
    export default {
        name: 'User',
        data(){
            return{
                size,UserFilled,
                Avatar,
                CirclePlus,
                Plus,
                Upload,
                //username:"王小虎",
                textarea,
                userinfoData,
                updateUserInfo,
                userinfo
            }
        },
        components: {
        }
    }
    const userinfoData = ref({
        phonenumber:'',
        password:'',
        realname:'',
        address:'',
        email:'',
        repassword:''
    })

    const size = ref(0)
    import { ref,reactive } from 'vue'
    import { UserFilled,Avatar,CirclePlus,Plus,Upload} from '@element-plus/icons-vue'
    const textarea=ref('')
    import {userInfoService} from "@/api/user";
    const userinfo=async ()=>{
        let result=await userInfoService();
        userinfoData.value=result.data;
    }
    userinfo();
    const updateUserInfo=async ()=>{
        let result=await userInfoUpdateService(userinfoData.value)
        ElMessage.success(result.msg?result.msg:"修改成功")
        userInfoStore.setUserInfo(userinfoData.value)
        router.push('/user/info')
    }
</script>

<style scoped>
span{
    text-align:left;
    /*float: left;*/
    width: 240px;
}/*.al-left{
    
    text-align: left;
}*/

.infobar{
    box-shadow: var(--el-box-shadow-dark);
    box-shadow: -3px 0 8px -4px;
    border-radius: 4px;
    background-color: aliceblue;
    width: 300px;
    height: auto;
    padding: 20px;
    padding-top: 5px;
    padding-left: 60px;
    padding-right: 60px;
    margin-right: 100px;
    margin-left: 300px;
    margin-top: 0;
    text-align:center;
    /*display: flex;*/
    justify-content: center;
}
.el-form-item{
    margin-bottom: 4px;
    margin-top: 5px;
}
a{
  color: #409eff;
  text-decoration: none;
}
</style>
